import { useDeviceRoleStore } from '@/dataset/device-role/store'
import { useAppStore } from '@/pinia'

/**
 * 获取授权后首次载入
 * 运行在首个页面进入之前
 */
export function onAuthLaunch () {
  const deviceRoleStore = useDeviceRoleStore()
  const appStore = useAppStore()
  return new Promise(async (resolve) => {
    try {
      await Promise.any([
        // 加载平台信息
        appStore.reloadPlatformInfo(),
        // 获取设备权限
        deviceRoleStore.updateDeviceRole()
      ])
    } catch (e) {
    }
    resolve(undefined)
  })
}

/**
 * 首次载入
 * 运行在首个页面进入之前
 */
// export function onLaunch () {
//   return new Promise(async (resolve) => {
//     resolve(undefined)
//   })
// }
